package com.ashes.telbots.utils;

import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
import org.telegram.telegrambots.meta.api.objects.Message;

/**
 * @author chengxuhui
 * @description 工具类
 */
public class TelbotsUtils {
    //对获取到的tel用户信息进行处理,

    //自动回复
    public static SendMessage getAutoReply(Message msg) {
        return SendMessage.builder()
                .text("Hello!   " + msg.getFrom().getFirstName() + msg.getFrom().getLastName())
                .chatId(msg.getChatId().toString())
                .build();
    }

    //自动拉群
    public static SendMessage getAutoInviteGroup(Message msg) {
        return SendMessage.builder()
                .text("https://t.me/+3ANHK3b0N1tjODk1")
                .chatId(msg.getChatId().toString())
                .build();
    }

    //对接天气api, 实现自动回复天气   先实现北京
    public static SendMessage getWeatherInfo(Message msg) {
        StringBuilder weatherInfo = null;
        //调用获取天气方法类
        if (msg == null || msg.getText().equalsIgnoreCase("/weather")) {
            weatherInfo = WeatherUtils.getWeatherInfo("济南");
        } else {
            weatherInfo = WeatherUtils.getWeatherInfo(msg.getText());
        }
        return SendMessage.builder()
                .text(weatherInfo.toString())
                .chatId(msg.getChatId().toString())
                .build();
    }
}